﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApp4
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        public static   readonly Dictionary<string, string> _user = new Dictionary<string, string>();

        private void Form1_Load(object sender, EventArgs e)
        {
            _user.Add("quanguilan", "881234");
        }
           //登录
        private void Login_Click(object sender, EventArgs e)
        {
            //var  uName= "quanguilan";
            //var  pWord = "881234";

            
            var uid = userName.Text;
            var pwd = passWord.Text;

            var res = _user.Where(x => x.Key == uid).FirstOrDefault();

           // if (uName == uid && pWord == pwd)

           if(res .Key ==uid && res .Value ==pwd )
            {
                MessageBox.Show("登录成功", "恭喜你",MessageBoxButtons.OKCancel  ,MessageBoxIcon.Information  );
            }else
            {
                MessageBox.Show("登录失败,请你重新登录或者注册一个新账号","很遗憾", MessageBoxButtons.YesNo, MessageBoxIcon.Error );
            }

            }
                //注册
               private void Register_Click(object sender, EventArgs e)
        {

               Form2 form2 = new Form2();
               form2.Show();

        }
    }
}
